//
//  ViewController.swift
//  SkinPeeler
//
//  Created by xmg on 16/8/29.
//  Copyright © 2016年 wlis. All rights reserved.
//

import UIKit

class ViewController: UIViewController {

    @IBOutlet weak var skinHeightCons: NSLayoutConstraint!
    @IBOutlet weak var skinTopCons: NSLayoutConstraint!
    @IBOutlet weak var iconBtn: UIButton!
    @IBOutlet weak var bgImageView: UIImageView!
    @IBOutlet weak var textLabel: UILabel!
    override func viewDidLoad() {
        super.viewDidLoad()
        
    }

    override func viewWillAppear(animated: Bool) {
        super.viewWillAppear(animated)
        skinTopCons.constant = -44
        changeSkin()
    }
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }


}

extension ViewController{


    @IBAction func showSkinToolView(sender: UIBarButtonItem) {
        skinTopCons.constant = skinTopCons.constant == 0 ? -44 : 0
        /** 添加动画 */
        UIView.animateWithDuration(0.25) { () -> Void in
            self.view.layoutIfNeeded()
        }
    }
    @IBAction func SpringFestival(sender: UIButton) {
        SkinTools.setCurrentSkinName("chunjie")
        changeSkin()
    }
    
    @IBAction func MidautumnFestival(sender: UIButton) {
        SkinTools.setCurrentSkinName("zhongqiu")
        changeSkin()
    }
    @IBAction func NationalDay(sender: UIButton) {
        SkinTools.setCurrentSkinName("guoqing")
        changeSkin()
    }
    
    private func changeSkin(){
    
        bgImageView.image = SkinTools.imageWithIconName("back")
        iconBtn.setImage(SkinTools.imageWithIconName("icon"), forState: .Normal)
        textLabel.backgroundColor = SkinTools.TextBackgroundColor()
    }
    
}
